<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-bind</title>
    <style>
        .active {
            color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <p :title='title'>我是h1标签</p>
        <a :href="aHref">百度一下</a>
        <!--<p class="active">{{message}}</p>-->
        <!--<p :class="active">{{message}}</p>-->

        <!--<p v-bind:class="{key1: value1,key2: value2}"></p>-->
        <!--<p v-bind:class="{类名1: boolean,key2: boolean}"></p>-->
        <!--当boolean值为true时标签获得类名，为false时标签不获得类名-->
        <p :class="{active: isActive,line: isLine}">{{message}}</p>
        <p class="title" :class="getClasses()">{{message}}</p>
        <!--可以继续用原方式添加class值，不会将其覆盖，只会合并到一起-->
        <button @click="btnClick">按钮</button>
    </div>
</body>
<script src="../js/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            title: '我是标题',
            aHref: 'http://www.baidu.com',
            message: '你好',
            isActive: true,
            isLine: false
        },
        methods: {
            btnClick() {
                this.isActive = !this.isActive
            },
            getClasses() {
                return {
                    active: this.isActive,
                    line: this.isLine
                }
            }
        }
    })
</script>

</html>